import * as echarts from '../../ec-canvas/echarts';
const app = getApp();
var usernum = null,
sumnum = null,
item = null;
function initChart(canvas, width, height) {
    const chart = echarts.init(canvas, null, {
        width: width,
        height: height
    });
    canvas.setChart(chart);

    var option = {
        backgroundColor: "#f7f7f7",
        color: ["#37A2DA", "#32C5E9", "#67E0E3"],
        series: [{
            name: '线下课程提交进度统计',
            min: 0,
            max: sumnum,
            type: 'gauge',
            detail: {
                formatter: '{value}人',
                fontSize: 20,
                color: '#03A9F4',
            },
            axisLine: {
                show: true,
                lineStyle: {
                    width: 15,
                    shadowBlur: 0,
                    color: [
                        [0.3, '#6bc3ea'],
                        [0.7, '#40b6ea'],
                        [1, '#19C594']
                    ]
                }
            },
            data: [{
                value: usernum,
                name: '提交进度',
            }]

        }]
    };

    chart.setOption(option, true);

    return chart;
}

Page({
    data: {
        ec: {
            onInit: initChart
        },
        item:null
    },
    onLoad: function (options) {
        var _this = this;
        usernum = options.usernum;
        sumnum = options.sumnum;
        item = options.item
        _this.setData({
            item: options.item
        })
    },
    onReady() {
        this.setData({
            item: item
        })
    }
});
